package test;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class MongoApp {

    private static final Log log = LogFactory.getLog(MongoApp.class);

    public static void main(String[] args) throws Exception {
//
//        MongoOperations mongoOps = new MongoTemplate(new SimpleMongoClientDbFactory(MongoClients.create(), "database"));
//
//        Meet p = new Meet().setName("批斗大会").setAttendType(1);
//
//        // Insert is used to initially store the object into the database.
//        mongoOps.insert(p);
//        log.info("Insert: " + p);
//
//        // Find
//        p = mongoOps.findById(p.getId(), Meet.class);
//        log.info("Found: " + p);
//
//        // Update
//        mongoOps.updateFirst(query(where("name").is("Joe")), update("attendType", 35), Meet.class);
//        p = mongoOps.findOne(query(where("name").is("Joe")), Meet.class);
//        log.info("Updated: " + p);
//
//        // Delete
//        mongoOps.remove(p);
//
//        // Check that deletion worked
//        List<Meet> people = mongoOps.findAll(Meet.class);
//        log.info("Number of people = : " + people.size());
//
//
//        mongoOps.dropCollection(Meet.class);
    }
}
